// 邀请记录列表
<template>
    <div>
        <GoBack></GoBack>
        <div class="invitationListBox">
             <p class="adselfBox">邀请记录</p>
             <div class="MoneyHead">
                 <p class="title">今日共返现</p>
                 <p class="moneyNo">￥{{today_income}}</p>
                 <p class="moneyTips">平台累计返现金额:￥{{total_income}}</p>
             </div>
             <div class="ListCont">
                 <div class="listHead">
                     <div class="tabsBox flex flex-align-center flex-pack-center">
                         <!-- tab-on为选中 -->
                         <div class="tab" :class="{'tab-on':isActive == 1}" @click="changeTabFun('1')"><p>付费人数</p></div>
                         <div class="tab" :class="{'tab-on':isActive == 2}" @click="changeTabFun('2')"><p>续费人数</p></div>
                     </div>
                     <p class="text-tips">今日{{left_text}}人数:{{count_num_left}}  历史{{left_text}}人数:{{count_num_right}}</p>
                 </div>
                 <!-- 列表 -->
                 <div class="listCont" id='scrollDiv'>
                     <!-- item开始 -->
                     <div class="item flex flex-align-center" v-for='(item,index) in isListDate' :key='index'>
                        <div class="TimeBox">
                             <p>{{item.invitee_name}}</p>
                             <p class="timetips">{{item.create_time}}</p>
                         </div>
                         <p class="dttips">{{item.package_title}}</p>
                         <p class="Num">{{item.money}}元</p>
                     </div>
                 </div>
             </div>
        </div>
    </div>
</template>
<script>
import GoBack from '../goback'
export default {
    components: {
        GoBack
    },
    data () {
        return {
           isActive:1,
           isListDate:[],
           total_income:'', //平台总返利
           today_income:'', //今日返利
           count_num_left:'',
           count_num_right:'',
           left_text:'付费',
           count_pay_total:'', //累计付费人数
           count_pay_today:'',//今日付费人数
           count_renew_total:'', //累计续费人数
           count_renew_today:'', //今日续费人数
           type:1,
           page:1,
           stup:true,
        }
    },
    mounted () {
        this.getObtainInviteInfoById();
        this.getObtainInviteList();
        this.scroll();
    },
    methods: {
        changeTabFun(evet){
            if(evet == 1){
                this.left_text = '付费';
                this.type = evet;
                this.count_num_left = this.count_pay_today;
                this.count_num_right = this.count_pay_total;
                this.getObtainInviteList();
                this.isListDate=[];
                 this.page=1;
            }else{
                this.left_text = '续费';
                this.type = evet;
                this.count_num_left = this.count_renew_today;
                this.count_num_right = this.count_renew_total;
                this.getObtainInviteList();
                this.isListDate=[];
                 this.page=1;
            }
            this.type = evet;
            this.isActive = evet;
        },
        getObtainInviteInfoById(){ //获取邀请收益
            let uid = this.$store.state.userInfo.id;
            this.https('user/getObtainInviteInfoById',{uid:uid})
            .then(data => {
                this.total_income = data.total_income;
                this.today_income = data.today_income;
                this.count_num_left = data.count_pay_today;
                this.count_num_right = data.count_pay_total;
                this.count_pay_today = data.count_pay_today;
                this.count_pay_total = data.count_pay_total;
                this.count_renew_today = data.count_renew_today;
                this.count_renew_total = data.count_renew_total;
            })
        },
        getObtainInviteList(){ //邀请列表
            let uid = this.$store.state.userInfo.id;
            this.https('user/getObtainInviteList',{uid:uid,page:this.page,type:this.type})
            .then(data => {
                     if(data.data.length != ''){
                        for(let i in data.data){
                            this.isListDate.push(data.data[i]);
                        }
                        this.stup = true;
                    }else{
                        this.stup = false;
                    }
            })
        },
        scroll(){
            let _self = this;
            let scrollDiv = document.getElementById('scrollDiv');
            scrollDiv.addEventListener('scroll',function(){
                if(scrollDiv.scrollTop+scrollDiv.clientHeight == scrollDiv.scrollHeight && _self.stup){
                    _self.page ++;
                    _self.getObtainInviteList();
                }
            })
        }
    }
}
</script>
<style lang="less" scoped>
@import url(../../assets/css/usercenter/invitationlist.less);
</style>


